package com.nbgs.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nbgs.demo.common.Result;
import com.nbgs.demo.controller.form.ComplainNews;
import com.nbgs.demo.model.Complain;
import com.nbgs.demo.service.ComplainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@CrossOrigin("*")
public class ComplainController {
@Autowired
private ComplainService complainService;
    @GetMapping("showAll")
    public Result showAll(@RequestParam(defaultValue = "1")int currPage, @RequestParam(defaultValue = "10")int pageSize,@RequestParam String complainState){
        //通过cardNum展示投诉信息
        log.info("分页展示投诉信息{}{}{}",currPage,pageSize,complainState);
        Page<ComplainNews> pageParm = new Page<>();
        pageParm.setCurrent(currPage);
        pageParm.setSize(pageSize);
        pageParm.setTotal(complainService.getAll(complainState));
        IPage<ComplainNews> all = complainService.showAll(pageParm,complainState);
        return  Result.success(all);
    }
    //修改投诉状态
    @PutMapping("updateComplain")
    public Result updateComplain(ComplainNews complainNews){
        log.info("修改投诉状态{}",complainNews);
      //通过水卡id修改投诉的详情
        complainService.updateState(complainNews);
        return Result.success();
    }

}
